package mail.fetch.qq;

import com.han.http.client.paramter.RequestHeader;
import com.han.http.fetch.Fetcher;

import java.util.List;
import java.util.Map;

import static com.han.http.util.Print.printlnInfo;

/**
 * @Author: hanjiafeng
 * @Date: update at 2019-1-25 14:31:18
 * @Desc: 收件箱
 */
@Deprecated
public class Inbox {
    private Fetcher fetcher;

    public Inbox() {
        fetcher = new Fetcher();
    }

    public void getMailBrief(Map<String, String> cookieRepository) throws Exception {
        String url = "https://mail.fetch.qq.com/cgi-bin/mail_list?sid=" + cookieRepository.get("sidu") + "&folderid=1&folderkey=1&page=0&s=inbox&topmails=0&showinboxtop=1&ver=737483.0&cachemod=maillist&cacheage=7200&r=";
        StringBuilder cookie = new StringBuilder();
        cookie.append(";ptui_loginuin=").append(cookieRepository.get("ptui_loginuin"))
                .append(";uin=").append(cookieRepository.get("uin"))
                .append(";skey=").append(cookieRepository.get("skey"))
                .append(";RK=").append(cookieRepository.get("RK"))
                .append(";ptcz=").append(cookieRepository.get("ptcz"))
                .append(";p_uin=").append(cookieRepository.get("p_uin"))
                .append(";pt4_token=").append(cookieRepository.get("pt4_token"))
                .append(";p_skey=").append(cookieRepository.get("p_skey"))
                .append(";wimrefreshrun=").append(cookieRepository.get("wimrefreshrun"))
                .append(";qm_flag=").append(cookieRepository.get("qm_flag"))
                .append(";qqmail_alias=").append(cookieRepository.get("qqmail_alias"))
                .append(";sid=").append(cookieRepository.get("sid"))
                .append(";qm_username=").append(cookieRepository.get("qm_username"))
                .append(";qm_lg=").append(cookieRepository.get("qm_lg"))
                .append(";new_mail_num=").append(cookieRepository.get("new_mail_num"))
                .append(";qm_domain=").append(cookieRepository.get("qm_domain"))
                .append(";qm_ptsk=").append(cookieRepository.get("qm_ptsk"))
                .append(";foxacc=").append(cookieRepository.get("foxacc"))
                .append(";ssl_edition=").append(cookieRepository.get("ssl_edition"))
                .append(";edition=").append(cookieRepository.get("edition"))
                .append(";newpt=").append(cookieRepository.get("newpt"))
                .append(";qm_loginfrom=").append(cookieRepository.get("qm_loginfrom"))
                .append(";username=").append(cookieRepository.get("username"))
                .append(";tinfo=").append(cookieRepository.get("tinfo"))
                .append(";CCSHOW=").append(cookieRepository.get("CCSHOW"));
        RequestHeader[] requestHeaders = {
                new RequestHeader("Host", "mail.fetch.qq.com"),
                new RequestHeader("Connection", "keep-alive"),
                new RequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"),
                new RequestHeader("Accept", "image/webp,image/apng,image/*,*/*;q=0.8"),
                new RequestHeader("Accept-Encoding", "gzip, deflate, br"),
                new RequestHeader("Accept-Language", "zh-CN,zh;q=0.9"),
                new RequestHeader("Cookie", cookie.toString())
        };
        Map<String, List<String>> map = fetcher.getAllInfoByGet(url, requestHeaders, 1000 * 3, 1000 * 3, false, null);

        printlnInfo("");
        printlnInfo("getMailBrief");
        printlnInfo(">>>" + url + "<<<");
        printlnInfo(">>>" + cookie + "<<<");
        printlnInfo(">>>" + map + "<<<");
        printlnInfo(">>>" + cookieRepository + "<<<");
        printlnInfo("getMailBrief");
        printlnInfo("");
    }
}
